﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FCMS
{
    public class PagingCriteria
    {
        public PagingCriteria()
        {
        }

        public PagingCriteria(int pageSize, int pageIndex)
        {
            this.PageSize = pageSize;
            this.PageIndex = pageIndex;
        }

        public int PageSize
        {
            get;
            set;
        }

        public int PageIndex
        {
            get;
            set;
        }

        public int TotalCount
        {
            get;
            set;
        }

        public void Validate()
        {
            if (PageSize <= 0)
            {
                throw new ArgumentOutOfRangeException("PageSize");
            }

            if (PageIndex < 0)
            {
                throw new ArgumentOutOfRangeException("PageIndex");
            }
        }

        public int MinRowCount
        {
            get
            {
                return (this.PageIndex - 1) * this.PageSize + 1;
            }
        }

        public int MaxRowCount
        {
            get
            {
                return this.PageSize * this.PageIndex;
            }
        }
    }
}
